home *** CD-ROM | disk | FTP | other *** search
/ Champak 103 / Vol 103.iso / games / starship.swf / scripts / DefineSprite_220 / frame_6 / DoAction.as
Text File  |  2010-03-13  |  7KB  |  272 lines

  1. actSpeed = Math.pow(Math.abs(vy) + Math.abs(vx * 0.7),2);
  2. vx *= _root.cst.slowdown;
  3. collision = 0;
  4. legL = false;
  5. legR = false;
  6. legC = false;
  7. if(_parent.matter.platform.hitTest(_X + sensorX[0],_Y + sensorY[0],true))
  8. {
  9.    collision++;
  10.    legL = true;
  11. }
  12. if(_parent.matter.platform.hitTest(_X + sensorX[1],_Y + sensorY[1],true))
  13. {
  14.    collision++;
  15.    legR = true;
  16. }
  17. if(_parent.matter.platform.hitTest(_X + sensorX[2],_Y + sensorY[2],true))
  18. {
  19.    collision++;
  20.    legC = true;
  21. }
  22. if(legL == true && legR != true)
  23. {
  24.    if(_parent.matter.platform.hitTest(_X + sensorX[1],_Y + sensorY[1] + 3.5,true))
  25.    {
  26.       rotate = 2;
  27.       maxrotate = 5;
  28.    }
  29.    else
  30.    {
  31.       rotate = 3;
  32.       maxrotate = 10;
  33.    }
  34. }
  35. if(legR == true && legL != true)
  36. {
  37.    if(_parent.matter.platform.hitTest(_X + sensorX[0],_Y + sensorY[0] + 3.5,true))
  38.    {
  39.       rotate = -2;
  40.       maxrotate = 5;
  41.    }
  42.    else
  43.    {
  44.       rotate = -3;
  45.       maxrotate = 10;
  46.    }
  47. }
  48. if(legL != true && legR != true)
  49. {
  50.    rotate = 0;
  51. }
  52. if(1 < collision)
  53. {
  54.    ground = true;
  55.    fireLeft.gotoAndStop("inactive");
  56.    fireRight.gotoAndStop("inactive");
  57.    bumpDamage();
  58.    vy = 0;
  59.    vx = 0;
  60.    if(0 >= actFuel)
  61.    {
  62.       gotoAndPlay(18);
  63.    }
  64.    if(Math.abs(_rotation) < maxrotate && rotate != 0)
  65.    {
  66.       _rotation = _rotation + rotate;
  67.       _Y = _Y + 0.2;
  68.    }
  69.    i = 5;
  70.    while(6 >= i)
  71.    {
  72.       bump();
  73.       i++;
  74.    }
  75. }
  76. else
  77. {
  78.    ground = false;
  79.    _rotation = _rotation * 0.9;
  80.    vy += _root.cst.gravity;
  81. }
  82. completeCollisionCheck();
  83. if(collision == true)
  84. {
  85.    if(_parent.matter.active.goal.hitTest(_X + sensorX[10],_Y + sensorY[10],true))
  86.    {
  87.       gotoAndStop(8);
  88.    }
  89.    collision = false;
  90.    i = 5;
  91.    while(9 >= i)
  92.    {
  93.       if(_parent.matter.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  94.       {
  95.          if(_parent.matter.danger.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  96.          {
  97.             gotoAndPlay(18);
  98.          }
  99.          if(_parent.matter.active.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  100.          {
  101.             if(_parent.matter.active.object_1.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  102.             {
  103.                _parent.matter.active.object_1.hit();
  104.             }
  105.             if(_parent.matter.active.object_2.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  106.             {
  107.                _parent.matter.active.object_2.hit();
  108.             }
  109.             if(_parent.matter.active.object_3.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  110.             {
  111.                _parent.matter.active.object_3.hit();
  112.             }
  113.             if(_parent.matter.active.object_4.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  114.             {
  115.                _parent.matter.active.object_4.hit();
  116.             }
  117.             if(_parent.matter.active.object_5.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  118.             {
  119.                _parent.matter.active.object_5.hit();
  120.             }
  121.             if(_parent.matter.active.object_6.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  122.             {
  123.                _parent.matter.active.object_6.hit();
  124.             }
  125.             if(_parent.matter.active.object_7.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  126.             {
  127.                _parent.matter.active.object_7.hit();
  128.             }
  129.             if(_parent.matter.active.object_8.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  130.             {
  131.                _parent.matter.active.object_8.hit();
  132.             }
  133.             if(_parent.matter.active.object_9.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  134.             {
  135.                _parent.matter.active.object_9.hit();
  136.             }
  137.             if(_parent.matter.active.object_10.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  138.             {
  139.                _parent.matter.active.object_10.hit();
  140.             }
  141.             if(_parent.matter.active.object_11.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  142.             {
  143.                _parent.matter.active.object_11.hit();
  144.             }
  145.             if(_parent.matter.active.object_12.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  146.             {
  147.                _parent.matter.active.object_12.hit();
  148.             }
  149.             if(_parent.matter.active.object_13.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  150.             {
  151.                _parent.matter.active.object_13.hit();
  152.             }
  153.             if(_parent.matter.active.object_14.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  154.             {
  155.                _parent.matter.active.object_14.hit();
  156.             }
  157.             if(_parent.matter.active.object_15.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  158.             {
  159.                _parent.matter.active.object_15.hit();
  160.             }
  161.             if(_parent.matter.active.object_16.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  162.             {
  163.                _parent.matter.active.object_16.hit();
  164.             }
  165.             if(_parent.matter.active.object_17.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  166.             {
  167.                _parent.matter.active.object_17.hit();
  168.             }
  169.             if(_parent.matter.active.object_18.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  170.             {
  171.                _parent.matter.active.object_18.hit();
  172.             }
  173.             if(_parent.matter.active.object_19.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  174.             {
  175.                _parent.matter.active.object_19.hit();
  176.             }
  177.             if(_parent.matter.active.object_20.hitTest(_X + sensorX[i],_Y + sensorY[i],true))
  178.             {
  179.                _parent.matter.active.object_20.hit();
  180.             }
  181.          }
  182.          else
  183.          {
  184.             bump();
  185.          }
  186.       }
  187.       i++;
  188.    }
  189. }
  190. checkBorderCollision();
  191. if(0 < actFuel)
  192. {
  193.    if(Key.isDown(Key.UP))
  194.    {
  195.       vy += ay;
  196.       actFuel -= burnFuelUp;
  197.       burnFuel();
  198.       fireDown.gotoAndStop("fire");
  199.    }
  200.    else
  201.    {
  202.       fireDown.gotoAndStop("inactive");
  203.    }
  204.    if(Key.isDown(Key.LEFT))
  205.    {
  206.       if(ground == true)
  207.       {
  208.          vy += ay;
  209.       }
  210.       vx -= ax;
  211.       actFuel -= burnFuelSide;
  212.       burnFuel();
  213.       fireRight.gotoAndStop("fire");
  214.       _rotation = _rotation * 0.98 + 1;
  215.       shootLeft = true;
  216.    }
  217.    else
  218.    {
  219.       fireRight.gotoAndStop("inactive");
  220.    }
  221.    if(Key.isDown(Key.RIGHT))
  222.    {
  223.       if(ground == true)
  224.       {
  225.          vy += ay;
  226.       }
  227.       vx += ax;
  228.       actFuel -= burnFuelSide;
  229.       burnFuel();
  230.       fireLeft.gotoAndStop("fire");
  231.       _rotation = _rotation * 0.98 - 1;
  232.       shootLeft = false;
  233.    }
  234.    else
  235.    {
  236.       fireLeft.gotoAndStop("inactive");
  237.    }
  238. }
  239. else
  240. {
  241.    fireLeft.gotoAndStop("inactive");
  242.    fireRight.gotoAndStop("inactive");
  243.    fireDown.gotoAndStop("inactive");
  244. }
  245. _X = _X + vx;
  246. _Y = _Y + vy;
  247. if(Key.isDown(Key.SPACE))
  248. {
  249.    if(0 < actShots)
  250.    {
  251.       if(_parent.shot.ready == true)
  252.       {
  253.          if(shootLeft != true)
  254.          {
  255.             _parent.shot._x = _X + 15;
  256.             _parent.shot._y = _Y - 8;
  257.             _parent.shot.vx = 3;
  258.          }
  259.          else
  260.          {
  261.             _parent.shot._x = _X - 15;
  262.             _parent.shot._y = _Y - 8;
  263.             _parent.shot.vx = -3;
  264.          }
  265.          _parent.shot.ready = false;
  266.          actShots--;
  267.          refreshShots();
  268.          _parent.shot.gotoAndPlay("shoot");
  269.       }
  270.    }
  271. }
  272.